package com.gtug.kz.almaty;

import android.app.Activity;
import android.content.Context;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class ReadTwitter extends WebView{

	public ReadTwitter(Context context, Activity act) {
		super(context);
		clearCache(true);
		getSettings().setJavaScriptEnabled(true);
		if(Tools.haveInternet(context)) {		
			final Activity activity = act;
			setWebChromeClient(new WebChromeClient() {
				public void onProgressChanged(WebView view, int progress) {
					// Activities and WebViews measure progress with different scales.
					// The progress meter will automatically disappear when we reach 100%
					activity.setProgress(progress * 1000);
				}
			});
			
			setWebViewClient(new WebViewClient() {
				public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
					view.loadUrl("file:///android_asset/503.html");
				}
			});
			loadUrl("http://mobile.twitter.com/searches?q=%23alagtug+OR+%23almatygtug+OR+from:AlmatyGTUG");
		} else {
			loadUrl("file:///android_asset/503.html");
		}
	}

}
